<?php 
	//$_POST["param"] 获取文本框的值;
	//$_POST["name"]  获取文本框的name属性值，通过该值来判断是哪个文本框请求处理，这样当有多个实时验证请求时可以指定同一个文件处理;
	//sleep(3);
    //echo 'y'        验证通过输出小写字母"y"，出错则输出相应错误信息;
    session_start();
    $name = $_POST['name'];
    if($name == 'code')
    {
        $param = $_POST["param"];
        $code =  $_SESSION['verify_py']['code'];
        if($param == $code)
        {
            echo 'y';
        }
        else
        {
            echo '验证码错误';
        }
    }
    else if($name == 'username')
    {
        require(dirname(__FILE__).'/global.php');            
        $param = $_POST["param"];
        $sql = "select UserName from talking_user where UserName = '$param'";
        $users = $db->query($sql);
        if(count($users)>0)
        {
            echo '用户名已存在';
        }
        else
        {
            echo 'y';
        }
        $db->close();
    }
    else if($name == 'email')
    {
        require(dirname(__FILE__).'/global.php');            
        $param = $_POST["param"];
        $sql = "select UserEmail from talking_user where UserEmail = '$param'";
        $users = $db->query($sql);
        if(count($users)>0)
        {
            echo '邮箱已经被注册';
        }
        else
        {
            echo 'y';
        }
        $db->close();
    }
    else if($name == 'useremail')
    {
        require(dirname(__FILE__).'/global.php');            
        $param = $_POST["param"];
        $sql = "select UserEmail from talking_user where UserEmail = '$param'";
        $users = $db->query($sql);
        if(count($users)>0)
        {
            echo 'y';              
        }
        else
        {            
            echo '邮箱未注册';
        }
        $db->close();
    }
    else if($name == 'bar')
    {
        require(dirname(__FILE__).'/global.php');            
        $param = $_POST["param"];
        $sql = "select BarName from talking_bar where BarName = '$param'";
        $bars = $db->query($sql);
        if(count($bars)>0)
        {
            echo '贴吧已存在';  
        }
        else
        {       
            echo 'y';                           
        }
        $db->close();
    }
    else
    {
        echo '参数发送错误';
    }
?>